package fictional.Common;

import java.util.SortedSet;

public class FriendRequests extends SocialElement<FriendRequestItem> {

	public FriendRequests(CharacterItem character) {
		this.character = character;
	}
	
	public void setRequests(SortedSet<FriendRequestItem> requests) {
		this.collection = requests;
	}
	
	public SortedSet<FriendRequestItem> getRequests(){
		return collection;
	}
	
	public void addRequest(FriendRequestItem request) {
		addItem(request);
	}
	
	public void removeRequest(FriendRequestItem request) {
		removeItem(request);
	}
	
	public boolean exists(FriendRequestItem request) {
		for (FriendRequestItem fri : collection ) {
			if (fri.getReceiver().getId() == request.getReceiver().getId()) {
				if (fri.getSender().getId() == request.getId()) 
					return true;
			} else if (fri.getReceiver().getId() == request.getSender().getId()) {
				if (fri.getSender().getId() == request.getReceiver().getId())
					return true;
			}
		}
		return false;
	}
}